'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app;
  // api 命名空间
  const apiV2Router = router.namespace('/api/v2');
  router.get('/', controller.home.index);

  // Login
  apiV2Router.post('/login/register', controller.login.register);
  apiV2Router.post('/login', controller.login.loginIn);
  apiV2Router.get('/login/signout', controller.login.signOut);

  // User
  apiV2Router.get('/user/info', controller.user.userInfo);

  // Follow
  apiV2Router.post('/friend/follow', controller.friend.follow);
  apiV2Router.get('/friend/recommend', controller.friend.recommend);

  // Topic
  apiV2Router.get('/topic/detail', controller.topic.topicDetail);
  apiV2Router.get('/topic/friend/list', controller.topic.friendsTopicList);

  apiV2Router.post('/topic/add', controller.topic.addTopic);
  apiV2Router.post('/topic/discuss/add', controller.topic.addDiscuss);
  apiV2Router.post('/topic/thumbs_up', controller.topic.giveThumbsUp);

  // Upload
  apiV2Router.get('/upload/qiniu_token', controller.upload.getQiniuToken);
  apiV2Router.post('/upload/posts', controller.upload.handlePosts);
};
